<style>
.checkbox-block {
margin: 60px 0 0 50px;
}
.button-block {
margin: 60px 0 0 50px;
}
</style>
<div class="checkbox-block">
<table class="table table-bordered table-striped">
<tr>
<td>
<input type="checkbox" name="checkboxs" value="1"/>1
<input type="checkbox" name="checkboxs" value="2"/>2
<input type="checkbox" name="checkboxs" value="3"/>3
<input type="checkbox" name="checkboxs" value="4"/>4
<input type="checkbox" name="checkboxs" value="5"/>5
</td>
</tr>
</table>
</div>
<div class="button-block">
<button class="btn btn-primary" id="button" onclick="show()">Click</button>
</div>
@section scripts
{
<script type="text/javascript">
function show() {
obj = document.getElementsByName("checkboxs");
check_value = [];
for (i in obj) {
if (obj[i].checked)
check_value.push(obj[i].value);
}
alert(check_value);
}
</script>
}
<input type="checkbox" id="CheckAll" name="CheckAll" /><span>All</span>
<script type="text/javascript">
$(document).ready(function () {
$("#CheckAll").click(function () {
if ($("#CheckAll").prop("checked")) {
$("input[name='checkboxs']").prop("checked", true);
} else {
$("input[name='checkboxs']").prop("checked", false);
}
})
})
</script>